package com.doctcloud.hisinfo.histable.domain.ordadm;

import com.baomidou.mybatisplus.annotation.TableName;
import com.doctcloud.common.core.annotation.NotZero;
import com.doctcloud.common.core.utils.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.doctcloud.common.core.annotation.Excel;
import lombok.*;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

import static com.doctcloud.common.core.utils.StringUtils.trim;

/**
 * @ClassName 医嘱
 * @Author samula
 * @Descripe product by com.doctcloud
 * @Data 2025-09-23 1:52
 **/
//@TableName("orders")
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@EqualsAndHashCode(of = {"patientId", "visitId", "orderNo","orderSubNo"})
public class OrdersDo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Excel(name = "患者ID")
    private String patientId;
    @Excel(name = "住院标识号",cellType = Excel.ColumnType.NUMERIC)
    @NotNull
    @NotZero
    private Integer visitId;
    @Excel(name = "医嘱号",cellType = Excel.ColumnType.NUMERIC)
    @NotNull
    @NotZero
    private Integer orderNo;
    @Excel(name = "医嘱子序号",cellType = Excel.ColumnType.NUMERIC)
    @NotNull
    @NotZero
    private Integer orderSubNo;
    @Excel(name = "长期标记",cellType = Excel.ColumnType.NUMERIC)
    private Integer repeatIndicator;
    @Excel(name="医嘱类别")
    private String orderClass;
    @Excel(name="医嘱文本")
    private String orderText;
    @Excel(name="医嘱项目代码")
    private String orderCode;
    @Excel(name="单次剂量",cellType = Excel.ColumnType.NUMERIC)
    private Double dosage;
    @Excel(name="计量单位")
    private String dosageUnits;
    @Excel(name="医嘱途径")
    private String administration;
    @Excel(name="持续时间")
    private Integer duration;
    @Excel(name="持续时间单位")
    private String durationUnits;
    @Excel(name="启用时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startDateTime;
    @Excel(name="停用时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date stopDateTime;
    @Excel(name="频率描述")
    private String frequency;
    @Excel(name="频率次数",cellType = Excel.ColumnType.NUMERIC)
    private Integer freqCounter;
    @Excel(name="频率间隔",cellType = Excel.ColumnType.NUMERIC)
    private Integer freqInterval;
    @Excel(name="频率间隔单位")
    private String freqIntervalUnit;
    @Excel(name="执行时间详细描述")
    private String freqDetail;
    @Excel(name="护士执行时间")
    private String performSchedule;
    @Excel(name="开医嘱医生")
    private String doctor;
    @Excel(name="停医嘱医生")
    private String stopDoctor;
    @Excel(name="开医嘱校对护士")
    private String nurse;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "录入时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date enterDateTime;
    @Excel(name="医嘱状态")
    private String orderStatus;
    @Excel(name="计价属性")
    private Integer billingAttr;
    @Excel(name="药品计价属性")
    private Integer drugBillingAttr;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "最后执行时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date lastPerformDateTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "最后计价时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date lastAcctingDateTime;
    @Excel(name = "开单科室代码")
    private String orderingDept;
    @Excel(name = "执行结果")
    private String performResult;

    @Data
    public static class primaryKey {
        private final String patientId;
        private final Integer visitId;
        private final Integer orderNo;
        private final Integer orderSubNo;
        public primaryKey(String patientId,Integer visitId, Integer orderNo,Integer orderSubNo) {
            this.patientId = patientId;
            this.visitId = visitId;
            this.orderNo = orderNo;
            this.orderSubNo = orderSubNo;
        }
    }

    public void setOrderClass(String orderClass) {
        this.orderClass = trim(orderClass);
    }

    public void setOrderText(String orderText) {
        this.orderText = trim(orderText);
    }

    public void setOrderCode(String orderCode) {
        this.orderCode = trim(orderCode);
    }

    public void setDosageUnits(String dosageUnits) {
        this.dosageUnits = trim(dosageUnits);
    }

    public void setAdministration(String administration) {
        this.administration = trim(administration);
    }

    public void setDurationUnits(String durationUnits) {
        this.durationUnits = trim(durationUnits);
    }

    public void setFrequency(String frequency) {
        this.frequency = trim(frequency);
    }

    public void setFreqIntervalUnit(String freqIntervalUnit) { this.freqIntervalUnit = trim(freqIntervalUnit);}

    public void setFreqDetail(String freqDetail) {
        this.freqDetail = trim(freqDetail);
    }

    public void setPerformSchedule(String performSchedule) {
        this.performSchedule = trim(performSchedule);
    }

    public void setDoctor(String doctor) {
        this.doctor = trim(doctor);
    }

    public void setStopDoctor(String stopDoctor) {
        this.stopDoctor = trim(stopDoctor);
    }

    public void setNurse(String nurse) {
        this.nurse = trim(nurse);
    }

    public void setPerformResult(String performResult) {  this.performResult = trim(performResult); }
}
